Skip to content

[ExecuTorch][WebGPU] Preserve Linear and Q4 embedding params across dynamic resize - #21483

Merged
meta-codesync[bot] merged 5 commits into
gh/JCNTH/203/basefrom
gh/JCNTH/203/head
Aug 7, 2026
Merged

[ExecuTorch][WebGPU] Preserve Linear and Q4 embedding params across dynamic resize#21483
meta-codesync[bot] merged 5 commits into
gh/JCNTH/203/basefrom
gh/JCNTH/203/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.

Problem
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

Solution

  • Before: build and resize populated control words independently, allowing immutable shader state to reset.
  • After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

Implementation

  • Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
  • EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
  • Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

Constraints
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
@exported-using-ghexport

Differential Revision: D113992326

Differential Revision: D113992326

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21483

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 31 Pending

As of commit b63add9 with merge base 28a7fac (image):

NEW FAILURES - The following jobs have failed:

  • Cadence Build & Test / cpu-test / test-aot / test-aot (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID B98E:1BCB3:38320EF:BF0C7FE:6A760B4C and timestamp 2026-08-07 16:43:56 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • Cadence Build & Test / cpu-test / test-ops / test-ops (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID CDC4:35D683:8212F5D:1B50AB6E:6A760B4B and timestamp 2026-08-07 16:43:55 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-testsuite-linux / test-backend-linux (qnn, models) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 9E96:1780A5:36E7F7A:BAE9AA5:6A760B8D and timestamp 2026-08-07 16:45:01 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-testsuite-linux / test-backend-linux (qnn, operators) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 83C0:303096:847FDF6:1BE44F2F:6A760B93 and timestamp 2026-08-07 16:45:07 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

[ghstack-poisoned]
JCNTH added a commit that referenced this pull request Jul 31, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 409033795
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
[ghstack-poisoned]
JCNTH added a commit that referenced this pull request Jul 31, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 409300312
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

  fbsource master

[ghstack-poisoned]
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
@meta-codesync
meta-codesync Bot merged commit 533541f into gh/JCNTH/203/base Aug 7, 2026
179 of 184 checks passed
@meta-codesync
meta-codesync Bot deleted the gh/JCNTH/203/head branch August 7, 2026 17:22
@meta-codesync
meta-codesync Bot temporarily deployed to cherry-pick-bot August 7, 2026 17:22 Inactive
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
…ynamic resize

Pull Request resolved: #21483

**Preserve immutable Linear and Q4 embedding shader controls across dynamic resize through typed parameter authorities.**

**Problem**
The Linear resize hook dropped has_bias, and the Q4 embedding resize path could drop is_linear_weight. Both defects produced correct build-time outputs but silently changed semantics after a live shape update.

**Solution**
- Before: build and resize populated control words independently, allowing immutable shader state to reset.
- After: each build/resize pair calls one typed helper while recomputing only live counts and dispatch.

**Implementation**
- Linear.cpp — make_linear_params preserves the bias flag across vec4 and tiled routes.
- EmbeddingQ4gsw.cpp — EmbeddingLayout and make_embedding_params preserve nibble layout across resize.
- Mirrors Vulkan runtime/graph/ops/impl/Linear.cpp and EmbeddingQ4gsw.cpp, which carry immutable shader controls through dynamic dispatch.

**Constraints**
WGSL bytes, shader selection, bindings, uniform sizes, queue-write counts, dispatch formulas, and pipeline topology are unchanged. Production handler code is smaller because duplicated field population and scalar captures are removed.

Co-authored-with: Claude Code.
ghstack-source-id: 411961489
@exported-using-ghexport

Differential Revision: [D113992326](https://our.internmc.facebook.com/intern/diff/D113992326/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants